﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.ServiceModel;
using System.Text;
using HF.WCF.DBService;

namespace HFDbWinService
{
    public partial class DbWinService : ServiceBase
    {
        List<ServiceHost> hostList = new List<ServiceHost>();
        public DbWinService()
        {
            InitializeComponent();
        }
        void registeService(Type serviceType)
        {
            ServiceHost host = new ServiceHost(serviceType);
            host.Open();
            hostList.Add(host);
        }
        protected override void OnStart(string[] args)
        {
            registeService(typeof(DatabaseService));
        }

        protected override void OnStop()
        {
            foreach (ServiceHost host in hostList)
            {
                host.Close();
            }
            hostList.Clear();
        }
    }
}
